<?php
/**
 * Created by PhpStorm.
 * User: 曹乐清
 * Date: 2017/3/24
 * Time: 14:26
 */

namespace Home\Controller;


class PhotoBoxController extends CommonController
{
    //@todo 加载相框相册规格页面
    public function index(){
        $this->display();
    }

    //@todo 新增规格
    public function add_PhotoBox(){
        $data=$_POST;
        $data['ac_time']=time();
        $id=D('photo_box')->add($data);
        if(!$id){
            $this->ajaxReturn(array('success'=>false,'message'=>'新增失败,请稍后再试'));
        }
        $this->ajaxReturn(array('success'=>true,'message'=>'新增成功'));
    }

    //@todo 获取列表
    public function getBoxList(){
        $count=D('photo_box')->count();
        $row=D('photo_box')->field("*,FROM_UNIXTIME(ac_time) as ac_time")->limit($_GET['offset'],$_GET['limit'])->order('type desc')->select();
        $this->ajaxReturn(array('rows'=>$row,'total'=>$count));
    }
    //@todo 删除
    public function del_box(){
        $id=D('photo_box')->delete($_GET['id']);
        if(!$id){
            $this->ajaxReturn(array('success'=>false,'message'=>'删除失败,请稍后再试'));
        }
        $this->ajaxReturn(array('success'=>true,'message'=>'新增成功'));
    }
}